Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure tests #93

Merged
merged 20 commits into from
Sep 5, 2022
Merged

Restructure tests #93

merged 20 commits into from
Sep 5, 2022

Conversation

qperrot
Copy link
Contributor

@qperrot qperrot commented Aug 31, 2022

Test for starkgate bridge with our link_token

@github-actions
Copy link

github-actions bot commented Aug 31, 2022

Smoke Test Results

1 tests  ±0   1 ✔️ ±0   6m 21s ⏱️ +4s
1 suites ±0   0 💤 ±0 
1 files   ±0   0 ±0 

Results for commit 1db4a8e. ± Comparison against base commit 63ced97.

♻️ This comment has been updated with latest results.

contracts/test/bridge/tokenBridge.ts Outdated Show resolved Hide resolved
contracts/test/bridge/tokenBridge.ts Outdated Show resolved Hide resolved
contracts/src/chainlink/solidity/mocks/TestERC20.sol Outdated Show resolved Hide resolved
contracts/test/bridge/tokenBridge.ts Outdated Show resolved Hide resolved
@qperrot qperrot temporarily deployed to integration September 1, 2022 09:12 Inactive
@qperrot qperrot temporarily deployed to integration September 1, 2022 09:22 Inactive
contracts/test/utils.ts Outdated Show resolved Hide resolved
contracts/test/bridge/tokenBridge.ts Outdated Show resolved Hide resolved
contracts/test/bridge/artifacts-test/Proxy.json Outdated Show resolved Hide resolved
contracts/src/chainlink/solidity/mocks/TestERC20.sol Outdated Show resolved Hide resolved
contracts/test/token/starkgate/behavior/ERC20.ts Outdated Show resolved Hide resolved
contracts/test/bridge/tokenBridge.ts Outdated Show resolved Hide resolved
contracts/test/bridge/tokenBridge.ts Outdated Show resolved Hide resolved
contracts/test/bridge/tokenBridge.ts Outdated Show resolved Hide resolved
contracts/test/bridge/tokenBridge.ts Outdated Show resolved Hide resolved
contracts/test/bridge/tokenBridge.ts Outdated Show resolved Hide resolved
@qperrot qperrot temporarily deployed to integration September 2, 2022 09:32 Inactive
@qperrot qperrot temporarily deployed to integration September 2, 2022 09:41 Inactive
contracts/package.json Outdated Show resolved Hide resolved
contracts/test/token/starkgate/behavior/ERC20.ts Outdated Show resolved Hide resolved
Comment on lines 8 to 28
`${__dirname}/../../../node_modules/internals-starkgate-contracts/artifacts/0.0.3/eth/${name}.json`,
)
.toString('ascii'),
)
}

export const loadOpenzepplinContract = (name: string): any => {
return json.parse(
fs
.readFileSync(
`${__dirname}/../../../node_modules/@openzeppelin/contracts/build/contracts/${name}.json`,
)
.toString('ascii'),
)
}

export const loadSolidityContract = (name: string): any => {
return json.parse(
fs
.readFileSync(
`${__dirname}/../../../contracts/artifacts/src/chainlink/solidity/mocks/${name}.sol/${name}.json`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's slightly unbelievable that we need to load contracts like this - very brittle.

For this PR please find all instances of functions like this (ctrl + F 'readFileSync') and please rename all these load functions to start with loadContract_ prefix so they are easily discoverable.

We'll need to go in as as a separate effort and figure out proper contract loading for both Cairo and Solidity.

NomicFoundation/hardhat#1040

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contracts/package.json Outdated Show resolved Hide resolved
contracts/test/token/starkgate/behavior/ERC20.ts Outdated Show resolved Hide resolved
packages-ts/integration-starkgate/test/tokenBridge.ts Outdated Show resolved Hide resolved
@qperrot qperrot temporarily deployed to integration September 2, 2022 13:10 Inactive
@qperrot qperrot temporarily deployed to integration September 2, 2022 13:18 Inactive
@qperrot qperrot temporarily deployed to integration September 2, 2022 13:29 Inactive
@qperrot qperrot temporarily deployed to integration September 2, 2022 13:38 Inactive
@qperrot qperrot temporarily deployed to integration September 2, 2022 13:42 Inactive
@qperrot qperrot temporarily deployed to integration September 2, 2022 13:45 Inactive
@qperrot qperrot temporarily deployed to integration September 2, 2022 13:56 Inactive
@qperrot qperrot temporarily deployed to integration September 2, 2022 14:13 Inactive
@qperrot qperrot temporarily deployed to integration September 2, 2022 14:24 Inactive
@krebernisak krebernisak temporarily deployed to integration September 3, 2022 16:07 Inactive
@krebernisak krebernisak temporarily deployed to integration September 3, 2022 16:08 Inactive
@krebernisak krebernisak temporarily deployed to integration September 3, 2022 16:14 Inactive
@krebernisak krebernisak temporarily deployed to integration September 3, 2022 16:23 Inactive
@krebernisak krebernisak temporarily deployed to integration September 3, 2022 16:48 Inactive
@krebernisak krebernisak temporarily deployed to integration September 3, 2022 16:56 Inactive
@krebernisak krebernisak temporarily deployed to integration September 3, 2022 17:05 Inactive
@krebernisak krebernisak temporarily deployed to integration September 4, 2022 12:09 Inactive
@krebernisak krebernisak temporarily deployed to integration September 4, 2022 12:18 Inactive
@krebernisak krebernisak temporarily deployed to integration September 4, 2022 14:40 Inactive
@krebernisak krebernisak temporarily deployed to integration September 4, 2022 14:49 Inactive
@krebernisak krebernisak temporarily deployed to integration September 4, 2022 18:02 Inactive
@krebernisak krebernisak temporarily deployed to integration September 4, 2022 18:11 Inactive
@krebernisak krebernisak temporarily deployed to integration September 4, 2022 18:26 Inactive
@krebernisak krebernisak temporarily deployed to integration September 4, 2022 18:36 Inactive
Comment on lines +180 to +196
test-integration-gauntlet: build-ts env-devnet-hardhat-down
cd packages-ts/starknet-gauntlet/ && \
yarn test
cd packages-ts/starknet-gauntlet-argent/ && \
yarn test
cd packages-ts/starknet-gauntlet-cli/ && \
yarn test
cd packages-ts/starknet-gauntlet-example/ && \
yarn test
cd packages-ts/starknet-gauntlet-multisig/ && \
yarn test
cd packages-ts/starknet-gauntlet-ocr2/ && \
yarn test
cd packages-ts/starknet-gauntlet-oz/ && \
yarn test
cd packages-ts/starknet-gauntlet-starkgate/ && \
yarn test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not rely on the toplevel yarn test which uses the Jest config to run all the tests? I personally only use that and ignore the Makefile

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version before this PR just ran Jest tests via root package.json test script.

The problem was not all workspace packages use Jest for testing - our contracts, example project, and 2x integration projects (multisig, starkgate) use hardhat + mocha, so they wouldn't be run.

Then I updated the root package.json test script to iterate over all projects and run their test scripts via "yarn workspaces run test" - but now the problem is Hardhat setup tests expect external network to be started already, and Gauntlet Jest tests run their own network (Integrated Devnet) on beforeAll. This was now a conflict because Integrated Devnet wouldn't start successfully if docker container was already running on the same 5050 port.

So for now I've split the two category of tests as different target, and different CI workflows. Now there is no infra conflict, and all tests are finally ran.

This is enough for this PR I'd say, and the plan for the next one is to restructure how do we run local env in tests as dependencies. Every tests suite should start its own network programatically in test setup, and tear it down when finished. At that point we can just run all tests at once via "yarn workspaces run test" and they would be even more isolated.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tldr; I consider this a temp workaround, and will try to remove it as test runs are restructured to be idempotent.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -29 to -30
"ts-node": "^10.4.0",
"typescript": "^4.5.2"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these required for tests?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are declared as part of <root>/package.json (just once, single version) and used by the whole yarn workspace. No need to redeclare them here, if a custom version is not required.

@krebernisak krebernisak merged commit 26eff08 into develop Sep 5, 2022
@krebernisak krebernisak deleted the restructure-tests branch September 5, 2022 09:46
@@ -3,18 +3,38 @@ import { StarknetContract, Account } from 'hardhat/types/runtime'
import { uint256 } from 'starknet'
import { toBN } from 'starknet/utils/number'
import { TIMEOUT } from '../../../constants'
import { expectInvokeError } from '../../../../test/utils'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe We can write it back to import { expectInvokeError } from '../../../utils'

@@ -1,38 +1,58 @@
import { constants, ec, encode, hash, number, uint256, stark, KeyPair } from 'starknet'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need all of it we can change it to import { constants, encode, number} from 'starknet'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants